﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RockScissorPaper
{
    public partial class Form1 : Form
    {
        private int playerwin = 0;
        private int computerwin = 0;
        public Form1()
        {
            InitializeComponent();

        }
        private void Rock_Click(object sender, EventArgs e)
        {
            var fistStr = "石头";
            Play(fistStr);
            
        }

        private void Scissor_Click(object sender, EventArgs e)
        {
            var fistStr = "剪刀";
            Play(fistStr);
        }

        private void Paper_Click(object sender, EventArgs e)
        {
            var fistStr = "布";
            Play(fistStr);
        }
        //游戏调用
        private void Play(string fistStr)
        {
            //玩家出石头
            labPlayer.Text = fistStr;
            var play = new Player();
            var enumPlay = play.ShowFist(fistStr);

            //电脑出拳
            var com = new Computer();
            var enumComputer = com.ShowFist();
            labComputer.Text = com.Fist.ToString();

            //裁判出场
            var enumResult = Judge.GetResult((int)enumPlay, (int)enumComputer);
            labJudge.Text = enumResult.ToString();
            //判断次数
            if (labJudge.Text == "玩家赢" && !(labJudge.Text == "平手"))
            {
                lblplayerwin.Text = playerwin.ToString();
                playerwin++;
            }
            if (labJudge.Text == "电脑赢" && !(labJudge.Text == "平手"))
            {
                lblcomputerwin.Text = computerwin.ToString();
                computerwin++;
            }
        }
    }
}
